package com.hugh.lagouapi.email;

import com.hugh.lagou.email.EmailService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Hugh
 * @Date: 2020/7/19
 */
@RestController
@RequestMapping("/api/email")
@Slf4j
public class EmailController {

    @Reference
    private EmailService emailService;

    /**
     * 发送验证码到邮箱
     * @param email 邮箱 ,验证码
     * @return 成功true，失败
     * false
     */
    @GetMapping("/send/{email}/{code}")
    public Boolean create(@PathVariable String email, @PathVariable String code){
        emailService.sendEmail(code, email);
        return Boolean.TRUE;
    }

    @GetMapping("/email/{email}/{code}")
    public Boolean test(@PathVariable String email, @PathVariable String code){
        log.info("this is /api/email/email************");
        return Boolean.TRUE;
    }

}
